package com.cndongtai.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.cndongtai.dao.BaseDao;
import com.cndongtai.dao.inter.LightConfigTemplateMapper;
import com.cndongtai.po.LightConfigTemplate;

@Repository("lightConfigTemplateDao")
public class LightConfigTemplateDao extends BaseDao implements LightConfigTemplateMapper {

	@Override
	public boolean addLightConfigTemplate(LightConfigTemplate lightConfigTemplate) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightConfigTemplateMapper operation = sqlSession.getMapper(LightConfigTemplateMapper.class);
			return operation.addLightConfigTemplate(lightConfigTemplate);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public List<LightConfigTemplate> queryConfigTemplateList(Long userId) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightConfigTemplateMapper operation = sqlSession.getMapper(LightConfigTemplateMapper.class);
			return operation.queryConfigTemplateList(userId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

	@Override
	public LightConfigTemplate queryConfigTemplateById(Integer templateId) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightConfigTemplateMapper operation = sqlSession.getMapper(LightConfigTemplateMapper.class);
			return operation.queryConfigTemplateById(templateId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

	@Override
	public boolean delLightConfigTemplate(Long templateId) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightConfigTemplateMapper operation = sqlSession.getMapper(LightConfigTemplateMapper.class);
			return operation.delLightConfigTemplate(templateId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

}
